class Tag < ActiveRecord::Base
    include Aggregator::TagModel
    
    include ModelHelper
    
    #    ##########################################################
    #    # Finds today's most used tags
    #    def self.todays_top(options = {})
    #        sql = 
    #          "SELECT t.id, t.name, COUNT(t.id) AS count FROM tags t INNER JOIN entries_tags ON entries_tags.tag_id = t.id WHERE t.created_at > '" + days_ago(1) + "' GROUP BY t.id, t.name"
    #        add_limit!(sql, options)
    #        
    #        result = connection.select_all(sql)
    #        count = result.inject({}) { |hsh, row| hsh[row['name']] = row['count'].to_i; hsh } unless options[:raw]
    #        count || result
    #    end
    #    
    #    ##########################################################
    #    # Finds most used tags
    #    def self.top(options = {})
    #        sql = "SELECT t.id, t.name, COUNT(t.id) AS count FROM tags t INNER JOIN feeds_users_tags ON feeds_users_tags.tag_id = t.id GROUP BY t.id, t.name " + 
    #		      "UNION " + 
    #		      "SELECT t.id, t.name, COUNT(t.id) AS count FROM tags t INNER JOIN entries_tags ON entries_tags.tag_id = t.id GROUP BY t.id, t.name"
    #        add_limit!(sql, options)
    #        
    #        result = connection.select_all(sql)
    #        count = result.inject({}) { |hsh, row| hsh[row['name']] = row['count'].to_i; hsh } unless options[:raw]
    #        count || result
    #    end
    #    
    #    ##########################################################
    #    # Finds tags applied by a user
    #    def self.tags_applied_by_user(user_id, entry_id, options = {})
    #        sql = "SELECT tags.name, tags.id, COUNT(tags.id) AS count " +
    #              "FROM entries_tags " +
    #              "INNER JOIN tags ON entries_tags.tag_id = tags.id " +
    #              "WHERE entries_tags.user_id = ? " +
    #              "GROUP BY tags.name, tags.id " +
    #              "ORDER BY count DESC"
    #        add_limit!(sql, options)
    #        self.find_by_sql([sql, user_id])
    #    end
    
end